﻿using CommonCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace ConsoleApp1
{

    public class A
    {
        public string Id { get; set; }
        public string UserName { get; set; }
        public string Age { get; set; }
        public string Sex { get; set; }
        public string UserAccount { get; set; }
        public string UserPwd { get; set; }
        public string RoleId { get; set; }
        public string startTime { get; set; }
        public string endTime { get; set; }
    }
    class Program
    {

        static void Main(string[] args)
        {
            A();
            Console.Read();
        }

        public static void A() 
        {
            B();
        }
        public static void B()
        {
            System.Diagnostics.StackFrame frame = new System.Diagnostics.StackFrame(1);
            System.Reflection.MethodBase method = frame.GetMethod();
            string namspace = method.DeclaringType.Namespace;
            string clasName = method.ReflectedType.Name;
            string meth = method.Name;
            string FullName = method.DeclaringType.FullName;
            Console.WriteLine(namspace);
            Console.WriteLine(clasName);
            Console.WriteLine(meth);
            Console.WriteLine(FullName);
        }
        private static string GenerateId()
        {
            string time = DateTime.Now.ToString("yyMMddHHmmssffff") + new Random().Next(0, 1000);

            return time;
        }
        public String GetPageString(string field, string tableName, int _pagerIndex, int _pagerSize, string WhereString, string _orderString)
        {
            StringBuilder sql = new StringBuilder();
            if (string.IsNullOrEmpty(_orderString))//排序不能为空
            {
                _orderString = " id desc";
            }
            sql.Append("(select row_number() over (order by " + _orderString + ") as rowId," + field + "from " + tableName);//查询语句
            if (!string.IsNullOrEmpty(WhereString))
            {
                sql.Append(" where " + WhereString);
            }
            if (_pagerIndex > 0)
            {
                _pagerIndex = _pagerIndex - 1;
            }
            int StartRecord = (_pagerIndex) * _pagerSize + 1;
            int EndRecord = StartRecord + _pagerSize - 1;
            string dd = sql.ToString();
            sql.Clear();
            sql.Append(" select * from " + dd + ") as t where rowId between " + StartRecord + " and " + EndRecord);
            //if (!string.IsNullOrEmpty(_orderString))
            //{
            // sql.Append(" ORDER BY " + _orderString);
            //}
            return sql.ToString();
        }


    }
}
